package com.dt.demo_goodservice.service.impl;

import com.dt.demo_goodservice.pojo.Goods;
import com.dt.demo_goodservice.service.GoodService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j  //启动链路追踪
public class GoodServiceImpl implements GoodService {

    private static final Map<Integer,Goods> map=new HashMap<>();

    @Value("${server.port}")
    private String port;  //取值器

    static{
        map.put(1,new Goods(1,"手机",1234.22));
        map.put(2,new Goods(2,"自行车",534.66));
        map.put(3,new Goods(3,"笔记本",3.5));
    }

    @Override
    public Goods findGoodsById(int id) {
        log.info("{----商品服务}");
        Goods gods= map.get(id);
        gods.setPort(port);
        System.out.println(port);
        return map.get(id);
    }

}
